package com.xsdl.singleton;

import java.util.concurrent.atomic.AtomicLong;

/*
 * 饿汉式单例模式,在项目启动的时候就创建好
 * 优点是随时可用,缺点是不支持延迟加载
 */
public class HIDGenerator {

    private final AtomicLong id = new AtomicLong(1L);

    private HIDGenerator() {

    }

    private static final HIDGenerator instance = new HIDGenerator();

    public static HIDGenerator getInstance() {
        return instance;
    }

    public Long getNextId() {
        return id.getAndIncrement();
    }

}
